package com.bee.auth.controller.web;

import com.bee.auth.client.AuthHolder;
import com.bee.auth.service.AuthService;
import com.bee.commons.vo.Result;
import com.bee.commons.web.constrants.WebConst;
import com.google.common.collect.Maps;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @author Damin.yang
 * @date 2019/08/16 11:16
 */
@Slf4j
@Api(tags = "后台权限模块")
@RestController(WebConst.MANAGEMENT + "/auth")
public class AuthController {

    private final static String MENUS = "menus";
    private final static String RESOURCES = "resources";

    @Autowired
    private AuthService authService;

    @ApiOperation(value = "获取用户权限信息", notes = "获取用户权限信息")
    @GetMapping()
    public Result<?> get() {
        Map<String, Object> map = Maps.newHashMap();
        map.put(MENUS, authService.getUserMenus(AuthHolder.getUserId()));
        map.put(RESOURCES, authService.getUserResources(AuthHolder.getUserId()));
        return Result.success(map);
    }

}
